<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@ include file="/WEB-INF/views/jsp/common/taglibs.jsp" %>
<head>
    <title>${platform_title}-登录</title>
    <%@ include file="/WEB-INF/views/jsp/common/meta.jsp" %>
    <link href="${ctx}/static/css/login.css" rel="stylesheet" type="text/css" media="all"/>
    <script type="text/javascript" src="${ctx}/static/lib/jquery/jquery-1.11.2.min.js"></script>
    <%@ include file="/WEB-INF/views/jsp/common/validate.jsp" %>
</head>
<body>
<div class="message warning">
    <div class="inset">
        <div class="login-head">
            <h1>Melody电商平台运营管理系统</h1>

            <div class="alert-close"></div>
        </div>

        <form id="loginForm" method="POST" action="/login"> 
            <ul>
                <li><input id="loginId" type="text" class="text" required/><a href="javascript:void(0);" class="icon user"></a></li>
                <li><input id="password" type="password" required/> <a href="javascript:void(0);" class="icon lock"></a></li>
            </ul>
            <div id="alertMsg" style="color: red;"></div>
            <div class="submit">
                <input type="submit" value="登录">
                <h4><a href="http://www.melody.top">登录商城?</a></h4>
                <div class="clear"></div>
            </div>
        </form>
    </div>
</div>

<!--- footer --->
<div class="footer">
    <p>Copyright &copy; 2016.10</p>
</div>
<script type="text/javascript">
    if (top != window) {
        top.location.href = window.location.href;
    }
    $(document).ready(function (c) {
        $('.alert-close').on('click', function (c) {
            $('.message').fadeOut('slow', function (c) {
                $('.message').remove();
            });
        });
        $("#loginForm").validate({
            submitHandler: function(form) {
                var loginId = $("#loginId").val();
                var password = $("#password").val();
                $.ajax({
                    url: '${ctx}/login',
                    data: {
                        loginId: loginId,
                        password:password
                    },
                    type: "POST",
                    dataType:"json",
                    success: function (data) {
                        if (data.statusCode == "1") {
                            window.location.href = "${ctx}/";
                        } else {
                            $("#alertMsg").html(data.msg);
                        }
                    }
                });

            }
        });
    });
</script>
</body>

</html>
